package com.ecar.api.rest.passenger;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ecar.api.rest.AbstractResource;
import com.ecar.api.service.common.DictionaryService;
import com.ecar.api.service.common.NotifyService;
import com.ecar.api.service.common.PriceCalculateService;
import com.ecar.api.service.driver.CarService;
import com.ecar.api.service.driver.DriverService;
import com.ecar.api.service.order.OrderPriceService;
import com.ecar.api.service.order.OrderService;
import com.ecar.api.service.passenger.PassengerOrderService;
import com.ecar.api.support.dto.Constants;
import com.ecar.api.support.dto.ReceiveOrSendDetailDto;
import com.ecar.api.support.util.DateUtil;
import com.ecar.api.support.util.OrderUtil;
import com.ecar.api.support.util.Props;
import com.ecar.api.support.util.RandomUtil;
import com.ecar.api.support.util.Redis;
import com.ecar.api.support.util.UserUtil;
import com.ecar.api.support.util.WilddogUtil;
import com.ecar.common.annotation.ResponseFilter;
import com.ecar.common.dto.DataBean;
import com.ecar.common.dto.Pager;
import com.ecar.common.exception.MyException;
import com.ecar.common.util.JSONUtil;
import com.ecar.common.util.StringUtil;
import com.ecar.core.common.entity.Dictionary;
import com.ecar.core.common.entity.User;
import com.ecar.core.driver.entity.Car;
import com.ecar.core.driver.entity.Driver;
import com.ecar.core.order.dao.OrderMapper;
import com.ecar.core.order.entity.Order;
import com.ecar.core.order.entity.OrderPriceDetail;
import com.ecar.core.order.entity.OrderPriceRule;
import com.ecar.core.passenger.entity.PaymentComment;
import com.wilddog.client.DataSnapshot;
import com.wilddog.client.SyncError;
import com.wilddog.client.ValueEventListener;

import net.sf.json.JSONObject;

@Controller
@Scope("prototype")
@Path("/passenger")
public class PassengerController extends AbstractResource {

	@Autowired
	OrderPriceService orderPriceService;

	@Autowired
	NotifyService notifyService;

	@Autowired
	PassengerOrderService passengerOrderService;

	@Autowired
	OrderService orderService;

	@Autowired
	PriceCalculateService priceCalculateService;

	@Autowired
	DriverService driverService;

	@Autowired
	CarService carService;

	@Autowired
	DictionaryService dictionaryService;

	/**
	 * 订单列表查询--快车
	 * 
	 * @param param
	 *            查询条件
	 * @return 订单列表
	 */
	@ResponseFilter(target = Order.class, fields = { "deleted" })
	@GET
	@Path("/{psId}/{pageNumber}/{pageSize}/{status}/getKcOrderList")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean getKcOrderList(@PathParam("psId") String psId, @PathParam("pageNumber") Integer pageNumber,
			@PathParam("pageSize") Integer pageSize, @PathParam("status") Integer status) {
		try {
			log.info("psID==================>" + psId);
			log.info("pageNumber==================>" + pageNumber);
			log.info("pageSize==================>" + pageSize);
			log.info("status==================>" + status);// 1.全部 2.未完成 3.已完成
			List<Order> list = new ArrayList<>();
			List<Integer> orderStatus = new ArrayList<>();
			List<Integer> payStatus = new ArrayList<>();
			Map<String, Object> model = new HashMap<String, Object>();
			Pager pager = new Pager();
			model.put("page1", (pageNumber - 1) * 10);
			model.put("page2", pageSize);
			switch (status) {
			case 1:
				// 全部
				log.info("快车--全部订单列表查询");
				model.put("psId", Integer.valueOf(psId));
				orderStatus.add(Constants.ORDER_OFF);
				orderStatus.add(Constants.ORDER_WAITING);
				orderStatus.add(Constants.ALREADY_GET_ORDER);
				orderStatus.add(Constants.ARRIVE_POINT);
				orderStatus.add(Constants.START_ROAD);
				orderStatus.add(Constants.END_ROAD);
				orderStatus.add(Constants.ALREADY_SEND_ORDER);
				payStatus.add(0);// 初始状态
				payStatus.add(Order.ST.CREATED.val());
				payStatus.add(Order.ST.PAID.val());
				payStatus.add(Order.ST.TIMEOUT.val());
				payStatus.add(Order.ST.REFUNDING.val());
				payStatus.add(Order.ST.REFUNDED.val());
				payStatus.add(Order.ST.FAILURE.val());

				model.put("orderStatus", orderStatus);
				model.put("payStatus", payStatus);
				list = passengerOrderService.getAllOrderListByQueryF(model);
				pager.setTotalCount(list.size());
				pager.setPageCount((list.size() + pageSize - 1) / pageSize);
				pager.setPageSize(pageSize);
				pager.setPageNumber(pageNumber);
				pager.setResult(list);
				break;
			case 2:
				// 未完成
				log.info("快车--未完成订单列表查询");
				model.put("psId", Integer.valueOf(psId));
				orderStatus.add(Constants.ORDER_WAITING);
				orderStatus.add(Constants.ALREADY_GET_ORDER);
				orderStatus.add(Constants.ARRIVE_POINT);
				orderStatus.add(Constants.START_ROAD);
				orderStatus.add(Constants.END_ROAD);
				orderStatus.add(Constants.ALREADY_SEND_ORDER);
				payStatus.add(0);// 初始状态
				payStatus.add(Order.ST.CREATED.val());
				payStatus.add(Order.ST.TIMEOUT.val());
				payStatus.add(Order.ST.REFUNDING.val());
				payStatus.add(Order.ST.FAILURE.val());
				model.put("orderStatus", orderStatus);
				model.put("payStatus", payStatus);

				list = passengerOrderService.getAllOrderListByQueryF(model);
				pager.setTotalCount(list.size());
				pager.setPageCount((list.size() + pageSize - 1) / pageSize);
				pager.setPageSize(pageSize);
				pager.setPageNumber(pageNumber);
				pager.setResult(list);
				break;
			case 3:
				// 已完成
				log.info("快车--已完成订单列表查询");
				model.put("psId", Integer.valueOf(psId));
				orderStatus.add(Constants.ORDER_OFF);
				orderStatus.add(Constants.END_ROAD);
				payStatus.add(0);// 取消订单时，支付状态为初始值0
				payStatus.add(Order.ST.PAID.val());
				payStatus.add(Order.ST.REFUNDED.val());

				model.put("orderStatus", orderStatus);
				model.put("payStatus", payStatus);

				list = passengerOrderService.getAllOrderListByQueryF(model);
				pager.setTotalCount(list.size());
				pager.setPageCount((list.size() + pageSize - 1) / pageSize);
				pager.setPageSize(pageSize);
				pager.setPageNumber(pageNumber);
				pager.setResult(list);
				break;
			default:
				return new DataBean(400, new JSONObject(), "乘客端快车订单列表请求参数错误！");
			}
			pager.setMessage("查询成功");
			return pager;

		} catch (Exception e) {
			log.info("乘客端快车订单列表查询异常", e.getMessage());
			if (e instanceof MyException) {
				return new DataBean(500, new JSONObject(), e.getMessage());
			} else {
				e.printStackTrace();
				return new DataBean(500, new JSONObject(), "乘客端快车订单列表查询失败，服务器异常。");
			}
		}
	}

	/**
	 * 订单列表查询--接送机
	 * 
	 * @param param
	 *            查询条件
	 * @return 订单列表
	 */
	@ResponseFilter(target = Order.class, fields = { "deleted" })
	@GET
	@Path("/{psId}/{pageNumber}/{pageSize}/{status}/getJsjOrderList")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean getJsjOrderList(@PathParam("psId") String psId, @PathParam("pageNumber") Integer pageNumber,
			@PathParam("pageSize") Integer pageSize, @PathParam("status") Integer status) {
		try {
			log.info("psID==================>" + psId);
			log.info("pageNumber==================>" + pageNumber);
			log.info("pageSize==================>" + pageSize);
			log.info("status==================>" + status);// 1.全部 2.未完成 3.已完成
			List<Order> list = new ArrayList<>();
			List<Integer> orderStatus = new ArrayList<>();
			List<Integer> payStatus = new ArrayList<>();
			Map<String, Object> model = new HashMap<String, Object>();
			Pager pager = new Pager();
			model.put("page1", (pageNumber - 1) * 10);
			model.put("page2", pageSize);
			switch (status) {
			case 1:
				// 全部
				log.info("接送机--全部订单列表查询");
				model.put("psId", Integer.valueOf(psId));
				orderStatus.add(Constants.ORDER_OFF);
				orderStatus.add(Constants.ORDER_WAITING);
				orderStatus.add(Constants.ALREADY_GET_ORDER);
				orderStatus.add(Constants.ARRIVE_POINT);
				orderStatus.add(Constants.START_ROAD);
				orderStatus.add(Constants.END_ROAD);
				orderStatus.add(Constants.ALREADY_SEND_ORDER);
				payStatus.add(0);// 取消订单时，支付状态为初始值0
				payStatus.add(Order.ST.CREATED.val());
				payStatus.add(Order.ST.PAID.val());
				payStatus.add(Order.ST.TIMEOUT.val());
				payStatus.add(Order.ST.REFUNDING.val());
				payStatus.add(Order.ST.REFUNDED.val());
				payStatus.add(Order.ST.FAILURE.val());

				model.put("orderStatus", orderStatus);
				model.put("payStatus", payStatus);
				list = passengerOrderService.getAllOrderListByQueryJS(model);
				pager.setTotalCount(list.size());
				pager.setPageCount((list.size() + pageSize - 1) / pageSize);
				pager.setPageSize(pageSize);
				pager.setPageNumber(pageNumber);
				pager.setResult(list);
				break;
			case 2:
				// 未完成
				log.info("接送机--未完成订单列表查询");
				model.put("psId", Integer.valueOf(psId));
				orderStatus.add(Constants.ORDER_WAITING);
				orderStatus.add(Constants.ALREADY_GET_ORDER);
				orderStatus.add(Constants.ARRIVE_POINT);
				orderStatus.add(Constants.START_ROAD);
				orderStatus.add(Constants.ALREADY_SEND_ORDER);
				orderStatus.add(Constants.END_ROAD);
				payStatus.add(0);// 初始状态
				payStatus.add(Order.ST.CREATED.val());
				payStatus.add(Order.ST.TIMEOUT.val());
				payStatus.add(Order.ST.REFUNDING.val());
				payStatus.add(Order.ST.FAILURE.val());

				model.put("orderStatus", orderStatus);
				model.put("payStatus", payStatus);
				list = passengerOrderService.getAllOrderListByQueryJS(model);
				pager.setTotalCount(list.size());
				pager.setPageCount((list.size() + pageSize - 1) / pageSize);
				pager.setPageSize(pageSize);
				pager.setPageNumber(pageNumber);
				pager.setResult(list);
				break;
			case 3:
				// 已完成
				log.info("接送机--已完成订单列表查询");
				model.put("psId", Integer.valueOf(psId));
				orderStatus.add(Constants.ORDER_OFF);
				orderStatus.add(Constants.END_ROAD);
				payStatus.add(0);// 初始状态
				payStatus.add(Order.ST.PAID.val());
				payStatus.add(Order.ST.REFUNDED.val());

				model.put("orderStatus", orderStatus);
				model.put("payStatus", payStatus);
				list = passengerOrderService.getAllOrderListByQueryJS(model);
				pager.setTotalCount(list.size());
				pager.setPageCount((list.size() + pageSize - 1) / pageSize);
				pager.setPageSize(pageSize);
				pager.setPageNumber(pageNumber);
				pager.setResult(list);
				break;
			default:
				return new DataBean(400, new JSONObject(), "接送机订单列表请求参数错误！");
			}
			pager.setMessage("查询成功");
			return pager;

		} catch (Exception e) {
			log.info("乘客端接送机订单列表查询异常", e.getMessage());
			if (e instanceof MyException) {
				return new DataBean(500, new JSONObject(), e.getMessage());
			} else {
				e.printStackTrace();
				return new DataBean(500, new JSONObject(), "乘客端接送机订单列表查询失败，服务器异常。");
			}
		}
	}
	
	
	/**
	 * 订单列表查询--接送机
	 * 
	 * @param param
	 *            查询条件
	 * @return 订单列表
	 */
	@ResponseFilter(target = Order.class, fields = { "deleted" })
	@GET
	@Path("/{psId}/{pageNumber}/{pageSize}/{status}/getJsjOrderList2")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean getJsjOrderList2(@PathParam("psId") String psId, @PathParam("pageNumber") Integer pageNumber,
			@PathParam("pageSize") Integer pageSize, @PathParam("status") Integer status) {
		try {
			log.info("psID==================>" + psId);
			log.info("pageNumber==================>" + pageNumber);
			log.info("pageSize==================>" + pageSize);
			log.info("status==================>" + status);// 1.全部 2.未完成 3.已完成
			List<Order> list = new ArrayList<>();
			List<Integer> orderStatus = new ArrayList<>();
			List<Integer> payStatus = new ArrayList<>();
			Map<String, Object> model = new HashMap<String, Object>();
			Pager pager = new Pager();
			model.put("page1", (pageNumber - 1) * 10);
			model.put("page2", pageSize);
			switch (status) {
			case 1:
				// 全部
				log.info("接送机--全部订单列表查询");
				model.put("psId", Integer.valueOf(psId));
				orderStatus.add(Constants.ORDER_OFF);
				orderStatus.add(Constants.ORDER_WAITING);
				orderStatus.add(Constants.ALREADY_GET_ORDER);
				orderStatus.add(Constants.ARRIVE_POINT);
				orderStatus.add(Constants.START_ROAD);
				orderStatus.add(Constants.END_ROAD);
				orderStatus.add(Constants.ALREADY_SEND_ORDER);
				payStatus.add(0);// 取消订单时，支付状态为初始值0
				payStatus.add(Order.ST.CREATED.val());
				payStatus.add(Order.ST.PAID.val());
				payStatus.add(Order.ST.TIMEOUT.val());
				payStatus.add(Order.ST.REFUNDING.val());
				payStatus.add(Order.ST.REFUNDED.val());
				payStatus.add(Order.ST.FAILURE.val());

				model.put("orderStatus", orderStatus);
				model.put("payStatus", payStatus);
				list = passengerOrderService.getAllOrderListByQueryJS2(model);
				pager.setTotalCount(list.size());
				pager.setPageCount((list.size() + pageSize - 1) / pageSize);
				pager.setPageSize(pageSize);
				pager.setPageNumber(pageNumber);
				pager.setResult(list);
				break;
			case 2:
				// 未完成
				log.info("接送机--未完成订单列表查询");
				model.put("psId", Integer.valueOf(psId));
				orderStatus.add(Constants.ORDER_WAITING);
				orderStatus.add(Constants.ALREADY_GET_ORDER);
				orderStatus.add(Constants.ARRIVE_POINT);
				orderStatus.add(Constants.START_ROAD);
				orderStatus.add(Constants.ALREADY_SEND_ORDER);
				orderStatus.add(Constants.END_ROAD);
				payStatus.add(0);// 初始状态
				payStatus.add(Order.ST.CREATED.val());
				payStatus.add(Order.ST.TIMEOUT.val());
				payStatus.add(Order.ST.REFUNDING.val());
				payStatus.add(Order.ST.FAILURE.val());

				model.put("orderStatus", orderStatus);
				model.put("payStatus", payStatus);
				list = passengerOrderService.getAllOrderListByQueryJS2(model);
				pager.setTotalCount(list.size());
				pager.setPageCount((list.size() + pageSize - 1) / pageSize);
				pager.setPageSize(pageSize);
				pager.setPageNumber(pageNumber);
				pager.setResult(list);
				break;
			case 3:
				// 已完成
				log.info("接送机--已完成订单列表查询");
				model.put("psId", Integer.valueOf(psId));
				orderStatus.add(Constants.ORDER_OFF);
				orderStatus.add(Constants.END_ROAD);
				payStatus.add(0);// 初始状态
				payStatus.add(Order.ST.PAID.val());
				payStatus.add(Order.ST.REFUNDED.val());

				model.put("orderStatus", orderStatus);
				model.put("payStatus", payStatus);
				list = passengerOrderService.getAllOrderListByQueryJS2(model);
				pager.setTotalCount(list.size());
				pager.setPageCount((list.size() + pageSize - 1) / pageSize);
				pager.setPageSize(pageSize);
				pager.setPageNumber(pageNumber);
				pager.setResult(list);
				break;
			default:
				return new DataBean(400, new JSONObject(), "接送机订单列表请求参数错误！");
			}
			pager.setMessage("查询成功");
			return pager;

		} catch (Exception e) {
			log.info("乘客端接送机订单列表查询异常", e.getMessage());
			if (e instanceof MyException) {
				return new DataBean(500, new JSONObject(), e.getMessage());
			} else {
				e.printStackTrace();
				return new DataBean(500, new JSONObject(), "乘客端接送机订单列表查询失败，服务器异常。");
			}
		}
	}

	/**
	 * 司机端订单详情
	 */
	@ResponseFilter(target = Order.class, fields = {})
	@GET
	@Path("/{orderNum}/getOrderPriceDetail")
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean driverOrderDetail(@PathParam("orderNum") String orderNum) {
		String massage = "";
		try {
			log.info("订单号参数=======>" + orderNum);

			Order order = orderService.selectByOrderNum(orderNum);
			if (order == null) {
				massage = "订单信息查询失败";
				log.info(massage);
				return new DataBean(400, new JSONObject(), massage);
			}
			Driver driver = driverService.selectByPrimaryKey(order.getDriverId());
			if (driver == null) {
				massage = "订单司机信息查询失败";
				log.info(massage);
				return new DataBean(400, new JSONObject(), massage);
			}
			Car car = carService.selectCarByDriverId(order.getDriverId());
			if (car == null) {
				massage = "订单司机车辆信息查询失败";
				log.info(massage);
				return new DataBean(400, new JSONObject(), massage);
			}
			int seatType = car.getSeatType();
			int orderType = order.getOrderType();
			OrderPriceRule orderPriceRule = priceCalculateService.selectPriceRule(seatType, orderType);
			List<ReceiveOrSendDetailDto> receiveOrSendDetailDtoList = new ArrayList<ReceiveOrSendDetailDto>();
			Dictionary dictionary = dictionaryService.selectByTheNode("0402");// 50元/位
			// 拼车详情
			if (orderType == 5 || orderType == 6) {
				List<Order> orderList = orderService.selectOrderByParentOrder(orderNum);
				for (Order shareCarOrder : orderList) {
					String sonOrder = shareCarOrder.getOrderNum();
					OrderPriceDetail sonorderPriceDetail = priceCalculateService.selectByOrderNum(sonOrder);
					ReceiveOrSendDetailDto receiveOrSendDetailDto = new ReceiveOrSendDetailDto();
					if (sonorderPriceDetail == null) {
						massage = "拼车订单价格详情查询失败,订单已取消";
						log.info(massage);
						receiveOrSendDetailDto.setBasePrice(orderPriceRule.getMinPrice());
						receiveOrSendDetailDto.setEmptyDriverPrice(0.00);
						receiveOrSendDetailDto.setLightDriverPrice(0.00);
						receiveOrSendDetailDto.setOverMileagePrice(0.00);
						receiveOrSendDetailDto.setOverTimePrice(0.00);
						receiveOrSendDetailDto.setTotalPrice(0.00);
						receiveOrSendDetailDto.setAddCharge(0.00);
						receiveOrSendDetailDto.setCreateTime(shareCarOrder.getCreateTime());
						receiveOrSendDetailDto.setDesAddress(shareCarOrder.getDesAddress());
						receiveOrSendDetailDto.setDriverLicense(car.getNumberPlate());
						receiveOrSendDetailDto.setDriverName(driver.getName());
						receiveOrSendDetailDto.setDriverPhone(driver.getPhone());
						receiveOrSendDetailDto.setOrderNum(shareCarOrder.getOrderNum());
						receiveOrSendDetailDto.setOrderStatus(shareCarOrder.getOrderStatus());
						receiveOrSendDetailDto.setPayStatus(shareCarOrder.getPayStatus());
						receiveOrSendDetailDto.setStartAddress(shareCarOrder.getStartAddress());
						receiveOrSendDetailDto.setUserPhone(shareCarOrder.getPassengerPhone());
						receiveOrSendDetailDto.setMenuRate(orderPriceRule.getMenuRate());
						receiveOrSendDetailDto.setPassRate(orderPriceRule.getPassRate());
						receiveOrSendDetailDto.setMenuMinute(orderPriceRule.getMenuTime());
						receiveOrSendDetailDto.setPassPrice(orderPriceRule.getPassTime());
						receiveOrSendDetailDto.setNullRate(orderPriceRule.getNullRate());
						receiveOrSendDetailDto.setNullPassRate(orderPriceRule.getNullPassRate());
						receiveOrSendDetailDto.setNightPrice(orderPriceRule.getNightPrice());
						receiveOrSendDetailDto.setUseSeats(shareCarOrder.getUseSeats());// 一口价座位
						receiveOrSendDetailDto.setUnitPrice(Double.valueOf(dictionary.getRemark()));// 一口价单价
						receiveOrSendDetailDto.setOrderType(order.getOrderType());
					} else {

						receiveOrSendDetailDto.setBasePrice(orderPriceRule.getMinPrice());
						receiveOrSendDetailDto.setEmptyDriverPrice(sonorderPriceDetail.getEmptyDriverPrice());
						receiveOrSendDetailDto.setLightDriverPrice(sonorderPriceDetail.getLightDriverPrice());
						receiveOrSendDetailDto.setOverMileagePrice(sonorderPriceDetail.getOverMileagePrice());
						receiveOrSendDetailDto.setOverTimePrice(sonorderPriceDetail.getOverTimePrice());
						receiveOrSendDetailDto.setTotalPrice(sonorderPriceDetail.getTotalPrice());
						receiveOrSendDetailDto.setAddCharge(sonorderPriceDetail.getAddCharge());
						receiveOrSendDetailDto.setCreateTime(shareCarOrder.getCreateTime());
						receiveOrSendDetailDto.setDesAddress(shareCarOrder.getDesAddress());
						receiveOrSendDetailDto.setDriverLicense(car.getNumberPlate());
						receiveOrSendDetailDto.setDriverName(driver.getName());
						receiveOrSendDetailDto.setDriverPhone(driver.getPhone());
						receiveOrSendDetailDto.setOrderNum(shareCarOrder.getOrderNum());
						receiveOrSendDetailDto.setOrderStatus(shareCarOrder.getOrderStatus());
						receiveOrSendDetailDto.setPayStatus(shareCarOrder.getPayStatus());
						receiveOrSendDetailDto.setStartAddress(shareCarOrder.getStartAddress());
						receiveOrSendDetailDto.setUserPhone(shareCarOrder.getPassengerPhone());
						receiveOrSendDetailDto.setMenuRate(orderPriceRule.getMenuRate());
						receiveOrSendDetailDto.setPassRate(orderPriceRule.getPassRate());
						receiveOrSendDetailDto.setMenuMinute(orderPriceRule.getMenuTime());
						receiveOrSendDetailDto.setPassPrice(orderPriceRule.getPassTime());
						receiveOrSendDetailDto.setNullRate(orderPriceRule.getNullRate());
						receiveOrSendDetailDto.setNullPassRate(orderPriceRule.getNullPassRate());
						receiveOrSendDetailDto.setNightPrice(orderPriceRule.getNightPrice());
						receiveOrSendDetailDto.setUseSeats(shareCarOrder.getUseSeats());// 一口价座位
						receiveOrSendDetailDto.setUnitPrice(Double.valueOf(dictionary.getRemark()));// 一口价单价
						receiveOrSendDetailDto.setOrderType(order.getOrderType());
					}

					receiveOrSendDetailDtoList.add(receiveOrSendDetailDto);
				}
				return new DataBean(200, receiveOrSendDetailDtoList, "订单详情查询成功");
			} else {
				OrderPriceDetail orderPriceDetail = priceCalculateService.selectByOrderNum(orderNum);
				if (orderPriceDetail == null) {
					massage = "订单价格详情查询失败";
					log.info(massage);
					return new DataBean(400, new JSONObject(), massage);
				}
				// 详情
				ReceiveOrSendDetailDto receiveOrSendDetailDto = new ReceiveOrSendDetailDto();
				// if(order.getOrderType()==1 || order.getOrderType()==2){
				receiveOrSendDetailDto.setBasePrice(orderPriceDetail.getBasePrice());
				receiveOrSendDetailDto.setEmptyDriverPrice(orderPriceDetail.getEmptyDriverPrice());
				receiveOrSendDetailDto.setLightDriverPrice(orderPriceDetail.getLightDriverPrice());
				receiveOrSendDetailDto.setOverMileagePrice(orderPriceDetail.getOverMileagePrice());
				receiveOrSendDetailDto.setOverTimePrice(orderPriceDetail.getOverTimePrice());
				receiveOrSendDetailDto.setTotalPrice(orderPriceDetail.getTotalPrice());
				receiveOrSendDetailDto.setAddCharge(orderPriceDetail.getAddCharge());
				// }else if(order.getOrderType()==3 || order.getOrderType()==4){
				// receiveOrSendDetailDto.setBasePrice(orderPriceDetail.getBasePrice());
				// receiveOrSendDetailDto.setO
				// verMileagePrice(orderPriceDetail.getOverMileagePrice());
				// receiveOrSendDetailDto.setLightDriverPrice(orderPriceDetail.getLightDriverPrice());
				// receiveOrSendDetailDto.setTotalPrice(orderPriceDetail.getTotalPrice());
				// }
				receiveOrSendDetailDto.setCreateTime(order.getCreateTime());
				receiveOrSendDetailDto.setDesAddress(order.getDesAddress());
				receiveOrSendDetailDto.setDriverLicense(car.getNumberPlate());
				receiveOrSendDetailDto.setDriverName(driver.getName());
				receiveOrSendDetailDto.setDriverPhone(driver.getPhone());
				receiveOrSendDetailDto.setOrderNum(orderNum);
				receiveOrSendDetailDto.setOrderStatus(order.getOrderStatus());
				receiveOrSendDetailDto.setPayStatus(order.getPayStatus());
				receiveOrSendDetailDto.setStartAddress(order.getStartAddress());
				receiveOrSendDetailDto.setUserPhone(order.getPassengerPhone());
				receiveOrSendDetailDto.setMenuRate(orderPriceRule.getMenuRate());
				receiveOrSendDetailDto.setPassRate(orderPriceRule.getPassRate());
				receiveOrSendDetailDto.setMenuMinute(orderPriceRule.getMenuTime());
				//时长费
				receiveOrSendDetailDto.setTimePrice(orderPriceDetail.getTimePrice());
				//时长单价
				receiveOrSendDetailDto.setPassPrice(orderPriceRule.getPassTime());
				//远途费
				receiveOrSendDetailDto.setLongDistancePrice(orderPriceDetail.getLongDistancePrice());
				//远途费单价
				receiveOrSendDetailDto.setLongDistanceUnitPrice(orderPriceRule.getLongDistancePrice());
				//远途费里程
				receiveOrSendDetailDto.setLongDistanceRate(orderPriceRule.getLongDistanceRate());
				
				receiveOrSendDetailDto.setNullRate(orderPriceRule.getNullRate());
				receiveOrSendDetailDto.setNullPassRate(orderPriceRule.getNullPassRate());
				receiveOrSendDetailDto.setNightPrice(orderPriceRule.getNightPrice());
				receiveOrSendDetailDto.setUseSeats(0);// 一口价座位,前端用不上的随便传值
				receiveOrSendDetailDto.setUnitPrice(0);// 一口价单价,前端用不上的随便传值
				receiveOrSendDetailDto.setOrderType(order.getOrderType());
				receiveOrSendDetailDtoList.add(receiveOrSendDetailDto);

				return new DataBean(200, receiveOrSendDetailDtoList, "订单详情查询成功");
			}

		} catch (Exception e) {
			log.info("订单详情查询失败:[{}], [{}]", massage, e.getMessage());

			if (e instanceof MyException) {
				return new DataBean(500, new JSONObject(), e.getMessage());
			} else {
				e.printStackTrace();
				return new DataBean(500, new JSONObject(), "订单详情查询失败，服务器异常。");
			}
		}
	}

	/**
	 * 乘客端订单详情
	 */
	@ResponseFilter(target = Order.class, fields = {})
	@GET
	@Path("/{orderNum}/{token}/getPassengerOrderPriceDetail")
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean passengerOrderDetail(@PathParam("orderNum") String orderNum, @PathParam("token") String token) {
		String massage = "";
		try {
			log.info("订单号参数=======>" + orderNum);
			log.info("订单号参数=======>" + token);
			OrderPriceDetail orderPriceDetail = priceCalculateService.selectByOrderNum(orderNum);
			if (orderPriceDetail == null) {
				massage = "订单价格详情查询失败";
				log.info(massage);
				return new DataBean(400, new JSONObject(), massage);
			}
			Order order = orderService.selectByOrderNum(orderNum);
			if (order == null) {
				massage = "订单信息查询失败";
				log.info(massage);
				return new DataBean(400, new JSONObject(), massage);
			}
			User user = UserUtil.getUser(order.getPassengerId(), token);
			if (user == null) {
				massage = "订单乘客信息查询失败";
				log.info(massage);
				return new DataBean(400, new JSONObject(), massage);
			}
			Driver driver = driverService.selectByPrimaryKey(order.getDriverId());
			if (driver == null) {
				massage = "订单司机信息查询失败";
				log.info(massage);
				return new DataBean(400, new JSONObject(), massage);
			}
			Car car = carService.selectCarByDriverId(order.getDriverId());
			if (car == null) {
				massage = "订单司机车辆信息查询失败";
				log.info(massage);
				return new DataBean(400, new JSONObject(), massage);
			}

			int orderNumber = orderService.queryDriverOrderNumber(driver.getId());

			int seatType = car.getSeatType();
			int orderType = order.getOrderType();
			OrderPriceRule orderPriceRule = priceCalculateService.selectPriceRule(seatType, orderType);
			Dictionary dictionary = dictionaryService.selectByTheNode("0402");// 50元/位
			// 详情
			ReceiveOrSendDetailDto receiveOrSendDetailDto = new ReceiveOrSendDetailDto();
			// if(order.getOrderType()==1 || order.getOrderType()==2){
			receiveOrSendDetailDto.setBasePrice(orderPriceDetail.getBasePrice());
			receiveOrSendDetailDto.setEmptyDriverPrice(orderPriceDetail.getEmptyDriverPrice());
			receiveOrSendDetailDto.setLightDriverPrice(orderPriceDetail.getLightDriverPrice());
			receiveOrSendDetailDto.setOverMileagePrice(orderPriceDetail.getOverMileagePrice());
			receiveOrSendDetailDto.setOverTimePrice(orderPriceDetail.getOverTimePrice());
			receiveOrSendDetailDto.setTotalPrice(orderPriceDetail.getTotalPrice());
			receiveOrSendDetailDto.setRoadTime(orderPriceDetail.getDriverTime());
			receiveOrSendDetailDto.setRoadDistance(orderPriceDetail.getRoadDistance());
			receiveOrSendDetailDto.setAddCharge(orderPriceDetail.getAddCharge());
			//远途费
			receiveOrSendDetailDto.setLongDistancePrice(orderPriceDetail.getLongDistancePrice());
			//远途费里程
			receiveOrSendDetailDto.setLongDistanceRate(orderPriceRule.getLongDistanceRate());
			//远途费单价
			receiveOrSendDetailDto.setLongDistanceUnitPrice(orderPriceRule.getLongDistancePrice());
			
			// }else if(order.getOrderType()==3 || order.getOrderType()==4){
			// receiveOrSendDetailDto.setBasePrice(orderPriceDetail.getBasePrice());
			// receiveOrSendDetailDto.setOverMileagePrice(orderPriceDetail.getOverMileagePrice());
			// receiveOrSendDetailDto.setLightDriverPrice(orderPriceDetail.getLightDriverPrice());
			// receiveOrSendDetailDto.setTotalPrice(orderPriceDetail.getTotalPrice());
			// }
			receiveOrSendDetailDto.setCreateTime(order.getCreateTime());
			receiveOrSendDetailDto.setDesAddress(order.getDesAddress());
			receiveOrSendDetailDto.setStartTime(order.getStartTime());
			receiveOrSendDetailDto.setEndTime(order.getEndTime());
			receiveOrSendDetailDto.setDriverId(order.getDriverId());
			receiveOrSendDetailDto.setDriverLicense(car.getNumberPlate());
			receiveOrSendDetailDto.setModel(car.getModel());
			receiveOrSendDetailDto.setDriverName(driver.getName());
			receiveOrSendDetailDto.setDriverPhone(driver.getPhone());
			receiveOrSendDetailDto.setDriverRates(driver.getRates());// 司机服务分
			receiveOrSendDetailDto.setAvatar(driver.getAvatar());// 司机头像
			receiveOrSendDetailDto.setOrderNumber(orderNumber);// 司机单数
			receiveOrSendDetailDto.setOrderNum(orderNum);
			receiveOrSendDetailDto.setOrderStatus(order.getOrderStatus());
			receiveOrSendDetailDto.setPayStatus(order.getPayStatus());
			receiveOrSendDetailDto.setStartAddress(order.getStartAddress());
			receiveOrSendDetailDto.setStartLocation(order.getStartLocation());
			receiveOrSendDetailDto.setDesLocation(order.getDesLocation());
			receiveOrSendDetailDto.setUserName(user.getUsername());
			receiveOrSendDetailDto.setUserPhone(user.getPhone());
			receiveOrSendDetailDto.setMenuRate(orderPriceRule.getMenuRate());
			receiveOrSendDetailDto.setPassRate(orderPriceRule.getPassRate());
			receiveOrSendDetailDto.setMenuMinute(orderPriceRule.getMenuTime());
			//时长费
			receiveOrSendDetailDto.setTimePrice(orderPriceDetail.getTimePrice());
			//时长单价(超时单价)
			receiveOrSendDetailDto.setPassPrice(orderPriceRule.getPassTime());
			receiveOrSendDetailDto.setNullRate(orderPriceRule.getNullRate());
			receiveOrSendDetailDto.setNullPassRate(orderPriceRule.getNullPassRate());
			receiveOrSendDetailDto.setNightPrice(orderPriceRule.getNightPrice());
			receiveOrSendDetailDto.setUseSeats(order.getUseSeats());// 一口价座位
			receiveOrSendDetailDto.setUnitPrice(Double.valueOf(dictionary.getRemark()));// 一口价单价
			receiveOrSendDetailDto.setOrderType(order.getOrderType());
			return new DataBean(200, receiveOrSendDetailDto, "订单详情查询成功");
		} catch (Exception e) {
			log.info("订单详情查询失败:[{}], [{}]", massage, e.getMessage());

			if (e instanceof MyException) {
				return new DataBean(500, new JSONObject(), e.getMessage());
			} else {
				e.printStackTrace();
				return new DataBean(500, new JSONObject(), "订单详情查询失败，服务器异常。");
			}
		}
	}

	/**
	 * 乘客端创建订单
	 * 
	 * @param param
	 *            查询条件
	 * @return 预估价格
	 */
	@ResponseFilter(target = Order.class, fields = {})
	@POST
	@Path("/createOrder")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean createOrder(JSONObject param) {

		if (!parse(param) || this.fields == null)
			return new DataBean(400, new JSONObject(), "请求参数格式错误！");

		DataBean dataBean = passengerOrderService.createOrder(fields);
		return dataBean;
	}

	/**
	 * 乘客端创建订单
	 * 
	 * @param param
	 *            查询条件
	 * @return 预估价格
	 */
	@ResponseFilter(target = Order.class, fields = {})
	@POST
	@Path("/createJSPOrder")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean createJSPOrder(JSONObject param) {

		if (!parse(param) || this.fields == null)
			return new DataBean(400, new JSONObject(), "请求参数格式错误！");

		DataBean dataBean = passengerOrderService.createJSPOrder(fields);
		return dataBean;
	}

	/**
	 * 匿名乘客下单创建订单
	 * 
	 * @param param
	 *            查询条件
	 * @return 预估价格
	 */
	@ResponseFilter(target = Order.class, fields = {})
	@POST
	@Path("/createF2FOrder")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean createF2FOrder(JSONObject param) {
		try {
			if (!parse(param) || this.fields == null)
				return new DataBean(400, new JSONObject(), "请求参数格式错误！");
			if (!this.fields.has("driverId") || !this.fields.has("useSeats") || !this.fields.has("startAddress")
					|| !this.fields.has("startLocation") || !this.fields.has("desAddress")
					|| !this.fields.has("desLocation") || !this.fields.has("passengerPhone")
					/*|| !this.fields.has("openid") || !this.fields.has("unionid") || !this.fields.has("device")
					|| !this.fields.has("deviceInfo")*/) {
				return new DataBean(500, new JSONObject(), "您有参数尚未填写");
			}
			String phone = fields.getString("passengerPhone");
			String driverId = fields.getString("driverId");
			String useSeats = fields.getString("useSeats");
			String startAddress = fields.getString("startAddress");
			String startLocation = fields.getString("startLocation");
			String desAddress = fields.getString("desAddress");
			String desLocation = fields.getString("desLocation");
			/*String openid = fields.getString("openid");
			String unionid = fields.getString("unionid");
			String device = fields.getString("device");
			String deviceInfo = fields.getString("deviceInfo");*/
			if (StringUtil.isEmpty(phone)/* || StringUtil.isEmpty(openid) || StringUtil.isEmpty(unionid)
					|| StringUtil.isEmpty(device) || StringUtil.isEmpty(deviceInfo)*/ || StringUtil.isEmpty(driverId)
					|| StringUtil.isEmpty(useSeats) || StringUtil.isEmpty(startAddress)
					|| StringUtil.isEmpty(startLocation) || StringUtil.isEmpty(desAddress)
					|| StringUtil.isEmpty(desLocation))
				return new DataBean(400, new JSONObject(), "手机号，乘客ID，座位数不能为空！");
			// 手机号验证
			Pattern patternP = Pattern.compile("^((13[0-9])|(14[5|7])|(15([0-9]))|(18[0-9]))\\d{8}$");
			Matcher matcherP = patternP.matcher(phone);
			if (!matcherP.matches())
				return new DataBean(403, new JSONObject(), "手机号有误");

			User user = UserUtil.getUserByPhone(phone);
			if (user == null) {
				log.info("96513的接口调用失败，乘客注册失败");
				return new DataBean(500, new JSONObject(), "下单失败，96513服务器暂时无法使用");
			}
			User passenger = new User();
			passenger.setId(user.getId());
			/*passenger.setDevice(device);
			passenger.setOpenid(openid);
			passenger.setUnionid(unionid);
			passenger.setDeviceInfo(deviceInfo);*/
			passenger.setPhone(phone);
			UserUtil.updateUserByUserId(passenger);
			Order order = JSONUtil.deserialize(fields, Order.class);
			if (driverService.selectByPrimaryKey(order.getDriverId()) == null) {
				return new DataBean(500, new JSONObject(), "司机id错误");
			}
			;
			int i = orderService.countUnendOrderByDriverId(order.getDriverId());
			if (i >= 1) {
				return new DataBean(500, new JSONObject(), "司机处于不可接单状态");
			}
			order.setPassengerId(passenger.getId());
			order.setPassengerPhone(phone);

			return passengerOrderService.createF2FOrder(order);
		} catch (Exception e) {
			log.info("面对面下单失败: {}", e.getMessage());
			if (e instanceof MyException) {
				return new DataBean(500, new JSONObject(), e.getMessage());
			} else {
				e.printStackTrace();
				return new DataBean(500, new JSONObject(), "下单失败，服务器异常。");
			}
		}
	}

	/**
	 * 乘客端获取接送机预估价
	 * 
	 * @param param
	 *            查询条件
	 * @return 预估价格
	 */
	@POST
	@Path("/getJSDepPrice")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean getJSDepPrice(JSONObject param) {

		try {
			if (!parse(param) || this.fields == null) {
				return new DataBean(400, new JSONObject(), "请求参数格式错误！");
			}

			return orderPriceService.getJSPrePrice(fields);

		} catch (Exception e) {
			e.printStackTrace();
			return new DataBean(500, new JSONObject(), "服务器内部错误！");
		}
	}

	/**
	 * 乘客端获取快车拼车预估价
	 * 
	 * @param param
	 *            查询条件
	 * @return 预估价格
	 */
	@POST
	@Path("/getKPDepPrice")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean getKPDepPrice(JSONObject param) {

		try {
			if (!parse(param) || this.fields == null) {
				return new DataBean(400, new JSONObject(), "请求参数格式错误！");
			}

			return orderPriceService.getKPDepPrice(fields);

		} catch (Exception e) {
			e.printStackTrace();
			return new DataBean(500, new JSONObject(), "服务器内部错误！");
		}
	}

	/**
	 * 匿名乘客下单一口价
	 * 
	 * @param param
	 *            查询条件
	 * @return 预估价格
	 */
	@GET
	@Path("/{useSeats}/getJSDepPrice")
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean getBCPrice(@PathParam("useSeats") Integer useSeats) {

		try {
			// 一口价的价格在数据字典表里
			Dictionary dictionary = dictionaryService.selectByTheNode("0402");

			Integer price = Integer.valueOf(dictionary.getRemark());
			price = useSeats * price;
			Map<String, Integer> result = new HashMap<String, Integer>();
			result.put("price", price);
			return new DataBean(200, result, "匿名乘客查询价格成功");

		} catch (Exception e) {
			e.printStackTrace();
			return new DataBean(500, new JSONObject(), "服务器内部错误！");
		}
	}

	/**
	 * 乘客端取消订单
	 * 
	 * @param param
	 *            查询条件
	 * @return 预估价格
	 */
	@POST
	@Path("/cancelOrder")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean cancelOrder(JSONObject param) {

		try {
			if (!parse(param) || this.fields == null) {
				return new DataBean(400, new JSONObject(), "请求参数格式错误！");
			}
			DataBean bean = orderService.cancelOrder(fields);
			// fire 删除野狗乘客的订单
			if (bean.getCode() == 200) {
				final String orderNum = fields.getString("orderNum");
				Order tempOrder = new Order();
				tempOrder.setOrderNum(orderNum);
				tempOrder.setEndTime(new Date());
				orderService.updateByOrderNumSelective(tempOrder);
				final Order order = orderService.selectByOrderNum(orderNum);
				final String driverId = order.getDriverId();
				WilddogUtil.removePassengerOrder(this.fields.getString("orderNum"));
				if (StringUtil.isNotEmpty(driverId)) {
					// fire 取消订单时，修改司机野狗数据
					WilddogUtil.getDriverRef("WilddogLocation/order").child(driverId)
							.addListenerForSingleValueEvent(new ValueEventListener() {
								@Override
								public void onDataChange(DataSnapshot dataSnapshot) {
									if (dataSnapshot.hasChild("now/" + orderNum)) {
										HashMap<String, Object> map = new HashMap<String, Object>();
										Driver driver = driverService.selectByPrimaryKey(driverId);
										map = orderService.sendToDriver(order, driver, 2, "");
										WilddogUtil.getDriverRef("WilddogLocation/order").child(driverId).child("now")
												.updateChildren(map);
									}
								}

								@Override
								public void onCancelled(SyncError arg0) {
								}
							});
					// 如果乘客取消了一个预约单，需要通知司机订单取消了
					if ((order.getOrderType() != 3 && order.getOrderType() != 5)) {
						String content = Props.getValue("sms.msg.appointment.cancel");
						content = MessageFormat.format(content,
								DateUtil.parseDateToString(order.getPlanTime(), "yyyy-MM-dd HH:mm:ss"),
								order.getStartAddress(), order.getDesAddress());
						notifyService.sendSingleSMS(driverService.selectByPrimaryKey(driverId).getPhone(), content);
					}
					if (order.getOrderType() == 5) {
						// 取消订单时，给车上加座位
						int seat = order.getUseSeats();
						String leftSeatKey = Redis.K.ORDER_CARPOOL.to(order.getOrderNum());
						if (!Redis.c.exists(leftSeatKey)) {
							log.info("redis没有该订单{}座位数", order.getOrderNum());
						} else {
							String leftSeatString = Redis.c.get(leftSeatKey);
							Integer leftSeat = Integer.valueOf(leftSeatString);
							leftSeat += seat;
							int EXPIRE = 7200;
							Redis.c.setex(Redis.K.ORDER_CARPOOL.to(order.getOrderNum()), EXPIRE,
									String.valueOf(leftSeat));
						}
						log.info("拼车单取消订单时，为司机排序");
						List<Order> list = orderService.selectOrderByParentOrder(order.getParentOrder());
						for (int i = 0; i < list.size(); i++) {
							if (list.get(i).getOrderStatus() == 6 || list.get(i).getOrderStatus() == 1) {
								list.remove(i);
								i--;
								continue;
							}
							/*
							 * if(list.get(i).getOrderNum().equals(orderNum)){
							 * list.remove(i); i--; continue; }
							 */
						}
						if (list.size() == 0) {
							driverService.startGetOrder(driverId);
						}
						OrderUtil.sortOrder(list);
					} else {
						driverService.startGetOrder(driverId);
					}
				}
			}
			return bean;
		} catch (Exception e) {
			e.printStackTrace();
			return new DataBean(500, new JSONObject(), "服务器内部错误！");
		}
	}

	/**
	 * 订单计费规则（订单预估金额使用）
	 * 
	 * @param param
	 *            查询条件
	 * @return 预估价格
	 */
	@GET
	@Path("/{carLevel}/{serviceType}/orderForecastPrice")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean orderForecastPrice(@PathParam("carLevel") int carLevel, @PathParam("serviceType") int serviceType) {
		try {
			OrderPriceRule orderPriceRule = orderPriceService.queryOrderPriceRule(carLevel, serviceType);

			return new DataBean(200, orderPriceRule, "订单计费规则详情调用成功!");

		} catch (Exception e) {
			e.printStackTrace();
			return new DataBean(500, new JSONObject(), "服务器内部错误！");
		}
	}

	/**
	 * txp 乘客端登陆检测是否有未完成订单
	 * 
	 * @param param
	 *            查询条件
	 * @return 未支付订单号
	 */
	@ResponseFilter(target = Order.class, fields = {})
	@GET
	@Path("/{passengerId}/recover")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean login(@PathParam("passengerId") int passengerId) {

		try {
			return passengerOrderService.login(passengerId);
		} catch (Exception e) {
			e.printStackTrace();
			return new DataBean(500, new JSONObject(), "服务器开了个小差,请联系客服！");
		}
	}

	/**
	 * 网约车查询可开发票订单
	 * 
	 * @param param
	 *            乘客id
	 * @return
	 */
	@GET
	@Path("/{passengerId}/invoiceMoney")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean getInvoiceTotalMoney(@PathParam("passengerId") int passengerId) {
		// User user = userService.selectByTypeAndId(Constants.USER_PASSENGER,
		// passengerId);
		// User user = UserUtil.getUser(fields.getInt("passengerId"),
		// fields.getString("token"));
		// if (null==user) {
		// return new DataBean(500, new JSONObject(), "乘客id错误!");
		// }

		return orderService.getInvoiceMoney(passengerId);
	}

	/**
	 * 网约车发票开具
	 * 
	 * @param param
	 *            参数
	 * @return
	 */
	@POST
	@Path("/getInvoice")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean getPayOrderList(JSONObject param) {
		if (!parse(param) || this.fields == null)
			return new DataBean(400, new JSONObject(), "请求参数格式错误！");

		return orderService.getInvoice(fields);
	}

	/**
	 * 查询订单支付状态
	 * 
	 * @param param
	 *            参数
	 * @return
	 */
	@GET
	@Path("/{orderNo}/getPayStatus")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public DataBean getPayStatus(@PathParam("orderNo") String orderNo) {
		return orderService.getPayStatus(orderNo);
	}

}
